package message.handler;

import java.util.List;

import message.CommunityStatusNotificaton;
import net.VirtualQueue;

import comunity.Community;
import comunity.User;

public class LoginHandler implements Runnable {

	String loggingUser;

	public LoginHandler(String loggingUser) {
		this.loggingUser = loggingUser;
	}

	@Override
	public void run() {
		Community community = Community.obtainCommunity();
		VirtualQueue virtualQueue = VirtualQueue.obtainVirtualQueue();

		List<User> contacts = community.getCommunityFor(loggingUser);
		int port = 0;//community.getUserInputPort(loggingUser);
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		CommunityStatusNotificaton csn = new CommunityStatusNotificaton(
				loggingUser, port, contacts);
		virtualQueue.pushHighPriorityMessage(csn);
	}



}
